#ifndef H_RCGD_STATUS_H
#define H_RCGD_STATUS_H 
#include "../includes.h"

/* STATUS format */
typedef struct STATUS_S{

    short   		ID;			/*  2 */

	time_			TIME;
	long			ANTDLY;
	char			Valid;
	char			LEAPSECOND;
	unsigned char			TIMEMODE;
	char			LOCALHOUR;
	char			LOCALMINUTE;

	char			PosSurvey;
	short			PosNo;
	short			PosCounter;
    P_  			CURRENT; 	/* 12 */
    P_  			AVERAGE;	/* 12 */
    P_  			LASTHELD;	/* 12 */

	TS_				TRACK;		/* 22 */

	OP_				OPERATION;	/*  4 */
	int				RunningTime;
	int				HoldoverCounter;
	char			HoldoverRecovery;

	char			ANTENNA;
    Diag_   		DIAG;		/* 10 */


    int   			DAC;        /*  4 */	/* Float -> Int */
    int     		TimeOffset;      /*  4 */
    int     		AvgTimeOffset; /*  4 */
    short   		T_OCXO;		/*  2 */
    short 			T_EXT;		/*  2 */

    short			Index;

    short   TAIL;       /*  2 */
} STATUS_;    /*  122 */

extern int Prev_DetailOffset;
extern int gCenter,gMax;


extern float Init_Temperature;
extern unsigned char Init_CounterModule_Status;
extern void DEBUG_OUT();

void Init_STATUS();

extern int iCntPeriodUdpReport;// = 0;
//extern int iPeriodUdpReport;// = 30;

#define	M_DEFINE_START_VALUE	5

void SetUpdMsgValue();
extern int bAlarmFalg ;
extern int iAlarmUdpReport ;


//#define SetAntOpen();	{buf_report.alarm.value.b.ant_open = 1;}
//#define ClrAntOpen();	{buf_report.alarm.value.b.ant_open = 0;}
//
//#define SetAntShort();	{buf_report.alarm.value.b.ant_short = 1;}
//#define ClrAntShort();	{buf_report.alarm.value.b.ant_short = 0;}
//
//#define QueryAntOpenOrShort() (buf_report.alarm.value.b.ant_open|| buf_report.alarm.value.b.ant_short)
//
//#define SetClk_na();	{buf_report.alarm.value.b.clk_na = 1;}
//#define ClrClk_na();	{buf_report.alarm.value.b.clk_na = 0;}
//
//#define SetGpsHoldover();	{buf_report.alarm.value.b.gps_holdover = 1;}
//#define ClrGpsHoldover();	{buf_report.alarm.value.b.gps_holdover = 0;}
//
//#define SetOcxoEfc();	{buf_report.alarm.value.b.ocxo_efc = 1;}
//#define ClrOcxoEfc();	{buf_report.alarm.value.b.ocxo_efc = 0;}
//
//#define SetOcxoFault();	{buf_report.alarm.value.b.ocxo_fault = 1;}
//#define ClrOcxoFault();	{buf_report.alarm.value.b.ocxo_fault = 0;}

#define SetAntOpen();	{buf_alm.value.b.ant_open = 1;}
#define ClrAntOpen();	{buf_alm.value.b.ant_open = 0;}

#define SetAntShort();	{buf_alm.value.b.ant_short = 1;}
#define ClrAntShort();	{buf_alm.value.b.ant_short = 0;}

#define QueryAntOpenOrShort() (buf_alm.value.b.ant_open|| buf_alm.value.b.ant_short)

#define SetClk_na();	{buf_alm.value.b.clk_na = 1;}
#define ClrClk_na();	{buf_alm.value.b.clk_na = 0;}

#define SetGpsHoldover();	{buf_alm.value.b.gps_holdover = 1;}
#define ClrGpsHoldover();	{buf_alm.value.b.gps_holdover = 0;}

#define SetOcxoEfc();	{buf_alm.value.b.ocxo_efc = 1;}
#define ClrOcxoEfc();	{buf_alm.value.b.ocxo_efc = 0;}

#define SetOcxoFault();	{buf_alm.value.b.ocxo_fault = 1;}
#define ClrOcxoFault();	{buf_alm.value.b.ocxo_fault = 0;}

#define OnceActiveCondition()	((SYSTEM.OPERATION.OPMODE == OPMODE_OPERATION) && (STATUS_Warmup == OFF))

#endif
